<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------

namespace Lg\Http;

/**
 * Description of Session
 *
 * @author Allen <allen@lg4.cn>
 */
class Session {

    public static function get($name, $default = null) {
        return \Lg\Session\Session::instance()->get($name, $default);
    }

    public static function set($name, $value) {
        return \Lg\Session\Session::instance()->set($name, $value);
    }

    public static function has($name) {
        return \Lg\Session\Session::instance()->has($name);
    }

    public static function remove($name) {
        return \Lg\Session\Session::instance()->remove($name);
    }

    public static function getPreviousUrl($default = null) {
        return \Lg\Session\Session::instance()->get('_lg_redirect', $default);
    }

    public static function setPreviousUrl($value) {
        return \Lg\Session\Session::instance()->set('_lg_redirect', $value);
    }

    /**
     * 
     * @param string $type (notice|error|success|warning|info)
     * @param string $message
     */
    public static function addFlash($type, $message) {
        \Lg\Session\Session::instance()->getFlashBag()->add($type, $message);
    }

    /**
     * 
     * @param string $type
     * @param array $default
     * @return string
     */
    public static function getFlash($type, array $default = array()) {
        return \Lg\Session\Session::instance()->getFlashBag()->get($type,
                        $default);
    }

    /**
     * 
     * @param string $type
     * @return array
     */
    public static function hasFlash($type) {
        return \Lg\Session\Session::instance()->getFlashBag()->has($type);
    }

    /**
     * 
     * @return array
     */
    public static function allFlash() {
        return \Lg\Session\Session::instance()->getFlashBag()->all();
    }

    /**
     * 
     * @return \Symfony\Component\HttpFoundation\Session\Flash\FlashBag
     */
    public static function flash() {
        return \Lg\Session\Session::instance()->getFlashBag();
    }

    public static function __callStatic($name, $arguments) {
        return call_user_func_array(array(\Lg\Session\Session::instance(), $name),
                $arguments);
    }

}
